﻿using FDEE.Model;
using FDEEDrawingModels;
using FDEEPublicFunc;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FDEEMain
{
    public partial class PileParamentForm : Form
    {
        FDEEReber fdeeReber;
        public InitTypePara para = new InitTypePara();
        List<ParaItem> items;
        private List<Control> _listParamCtrl = new List<Control>(); // 动态创建控件

        private double _scaleX = 1;
        private double _scaleY = 1;
        public FootingPara footingPara = new FootingPara();
        public PilePara pilePara = new PilePara();

        public PileParamentForm()
        {
            InitializeComponent();
            //plFMHK.Visible = false; ;
            using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero))
            {
                float dpiX = graphics.DpiX;
                float dpiY = graphics.DpiY;

                _scaleX += (dpiX - 96) * 1.041666 / 100;
                _scaleY += (dpiY - 96) * 1.041666 / 100;
            }
            InitForm();
            para = new InitTypePara();
        }
        private void InitForm()
        {

            InitType();
        }
        private void btnConfim_Click(object sender, EventArgs e)
        {
            try
            {
                pilePara = new PilePara();
                pilePara.type = cbPSubType.Text;
                pilePara.eSubType = ((CBItem)cbPSubType.SelectedItem).tag;                // 构造物子类型（枚举值）
                pilePara.pileDia = double.Parse(cbPDia.Text); // 墩高分类
                if (string.IsNullOrWhiteSpace(pileLength.Text))
                {
                    MessageBox.Show("请输入桩长", "提示");
                    return;
                }
                pilePara.pileLength = double.Parse(pileLength.Text);
                pilePara.DOWEL = double.Parse(dowel.Text);
                para.type = "Pile";
                para.eType = EStructure.E_PILE;// 构造物子类型（字符串）
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch
            {
                this.DialogResult = DialogResult.Cancel;
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }


        private void InitType()
        {

            cbPSubType.DisplayMember = "name";
            var values = Enum.GetValues(typeof(FDEE.Model.EPileType));
            foreach (var item in values)
            {
                CBItem data = new CBItem();
                int tag = (int)item;
                data.name = item.ToString();
                data.tag = tag;
                cbPSubType.Items.Add(data);
            }
            if(values.Length>1)
            {
                cbPSubType.SelectedIndex = 1;
            }
        }

   

   
    }
   
}
